package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mapper.BlackListMapper;
import com.tanhua.dubbo.mapper.UserInfoMapper;
import com.tanhua.model.pojo.BlackList;
import com.tanhua.model.pojo.UserInfo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class BlackListApiImpl implements BlackListApi{
    @Autowired
    private BlackListMapper blackListMapper;
    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public Page<UserInfo> findBlackList(Long userId, Integer page, Integer pageSize) {
        Page<UserInfo> pages = new Page(page, pageSize);
        pages = userInfoMapper.findBlackList(pages,userId);
        return pages;
    }

    @Override
    public void delete(Long userId, Long uid) {
        LambdaQueryWrapper<BlackList> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(BlackList::getUserId,userId);
        lambdaQueryWrapper.eq(BlackList::getBlackUserId,uid);
        blackListMapper.delete(lambdaQueryWrapper);
    }
}
